package com.microsoft;

import com.alibaba.fastjson.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.FileWriter;
import java.io.IOException;

/**
 * Created by zmkn2 on 2016/5/7.
 */
@Controller
public class MSController {

    @ResponseBody
    @RequestMapping(value = "test",method = RequestMethod.GET)
    public String test(){
        return "success";
    }

    @ResponseBody
    @RequestMapping(value = "aaa",method = RequestMethod.GET)
    public String aaa( Long id1,Long id2){
        /*写文件begin*/
        String filePath = App.class.getClassLoader().getResource("hop").getPath();
        System.out.println(filePath);
        try {
            FileWriter writer = new FileWriter(filePath, true);
            writer.write("id1:"+id1+" id2:"+id2+";");
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        /*写文件end*/


        App pr1 = new App();
        JSONArray result;
        result = pr1.process(id1,id2);
        //result即为返回的字符串
       // System.out.print(result.toString());
        return result.toString();
    }

}
